package com.css.zfzx.sjcj.modules.hddcGeologicalSvyLine.repository;

import com.css.zfzx.sjcj.modules.hddcGeologicalSvyLine.repository.entity.HddcGeologicalsvylineEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author lihelei
 * @date 2020-11-27
 */
@Repository
public interface HddcGeologicalsvylineRepository extends JpaRepository<HddcGeologicalsvylineEntity, String> {

    @Query(nativeQuery = true, value = "select * from hddc_geologicalsvyline where is_valid !=0 and project_name in :projectIds")
    List<HddcGeologicalsvylineEntity> queryHddcGeologicalsvylinesByProjectId(List<String> projectIds);

    @Query(nativeQuery = true, value = "select * from hddc_geologicalsvyline where is_valid !=0 and task_name in :taskIds")
    List<HddcGeologicalsvylineEntity> queryHddcGeologicalsvylinesByTaskId(List<String> taskIds);

    @Query(nativeQuery = true, value = "select * from hddc_geologicalsvyline where create_user = :createID and province = :provinceName and city =:cityName and area =:areaName")
    List<HddcGeologicalsvylineEntity> queryHddcGeologicalsvyplanninglinesByCreateuser(String createID,String provinceName,String cityName,String areaName);

    @Query(nativeQuery = true, value = "select * from hddc_geologicalsvyline where is_valid = '1'")
    List<HddcGeologicalsvylineEntity> findAll();

    @Modifying
    @Query(nativeQuery = true, value = "update hddc_geologicalsvyline set is_valid = '0' where province = :provinceName and city =:cityName and area =:areaName and extends8 =:savefilename")
    void deleteFileData(String provinceName,String cityName,String areaName,String savefilename);
}
